axios.interceptors.request.use(req=>{
    req.headers.accesstoken=localStorage.getItem("accessToken");
    return req;
})
axios.interceptors.response.use(resp=>{
    if (resp.headers.accesstoken!=null){
        localStorage.setItem("accessToken",resp.headers.accesstoken)
    }
    return resp;
})

new Vue({
    el:"#app",
    data:{
        accountInfo:{},
        updateObj:{},
        gender:[
            {
                value: 0,
                label:'女',
            },{
                value: 1,
                label:'男',
            }
        ],
        showInfo:false
        },
    methods:{
        loadInfo(){
            axios.get("/accountInfo/showMyInfo").then(resp=>{
                this.accountInfo=resp.data.data
            })
        },
        updateInfo(){
            this.showInfo=true;
            let objstr = JSON.stringify(this.accountInfo)
            this.updateObj = JSON.parse(objstr)
        },modify(){
            axios.post("/accountInfo/updateAccountInfo",this.updateObj).then(resp=>{
                alert(resp.data.message)
                if (resp.data.code==200){
                    this.showInfo=false
                    this.updateObj= {}
                    this.loadInfo()
                }
            })
        }
    },created(){
        this.loadInfo()
    }
})